package com.zjsru.oneDay;
/**
 * 递增的三元子序列
 *
 * 输入：nums = [1,2,3,4,5]
 * 输出：true
 * 解释：任何 i < j < k 的三元组都满足题意
 *
 * 输入：nums = [2,1,5,0,4,6]
 * 输出：true
 * 解释：三元组 (3, 4, 5) 满足题意，因为 nums[3] == 0 < nums[4] == 4 < nums[5] == 6
 *
 * */
public class increasingTriplet {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        if( n < 3){
            return false;
        }
        int first = nums[0], second = Integer.MAX_VALUE;
        for(int i = 1;i<n;i++){
            int num = nums[i];
            if(num > second){
                return true;
            }else if(num >first){
                second = num;
            }else{
                first = num;
            }
        }
        return false;

    }
    public static void main(String[] args){
        increasingTriplet increasingTriplet = new increasingTriplet();
        int[] nums = new int[]{2,1,5,0,4,6};
        System.out.println(increasingTriplet.increasingTriplet(nums));
    }
}
